#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

int main()
{
  umask(0);
  int fd1 = open("log1.txt", O_WRONLY|O_CREAT|O_APPEND, 0666);
  int fd2 = open("log2.txt",O_WRONLY|O_CREAT|O_APPEND,0666);
  int fd3 = open("log3.txt",O_WRONLY|O_CREAT|O_APPEND, 0666);
  int fd4 = open("log4.txt",O_WRONLY|O_CREAT|O_APPEND, 0666);

  printf("fd1: %d\n", fd1);
  printf("fd2:%d\n",fd2);
  printf("fd3:%d\n",fd3);
  printf("fd4:%d\n",fd4);

  return 0;
}


/*int main()
{
  int n = printf("stdin->fd:%d\n",stdin->_fileno);
  printf("stdout->fd:%d\n",stdout->_fileno);
  printf("stderr->fd:%d\n",stderr->_fileno);
  fprintf(stderr,"printf ret:%d\n",n);//将格式化数据写入流
  char buffer[1024];
  const char *msg = "hello Linux\n";
  write(1, msg, strlen(msg));
  write(2, msg, strlen(msg));

  return 0;
}*/ 






/*int main()
{
  const char* msg ="BLG VS WBG\n";
  fwrite(msg,strlen(msg),1,stdout);
  printf("hello printf!\n");
  fprintf(stdout,"hello fprintf!\n");
  fprintf(stderr,"hello stderr!\n");

  return 0;
}*/ 








/*int main()
{
  FILE* fp = fopen("text.txt","r");
  if(!fp)
  {
    printf("fopen error!\n");
  }
  char buf[1024];
  const char *msg="hel";
  while(1)
  {
    size_t s = fread(buf,1,strlen(msg),fp);
    if(s>0)
    {
      buf[s]=0;
      printf("%s",buf);
    }
  
    if(feof(fp))
    {
        break;
    }
  }
  fclose(fp);

  return 0;
}*/ 

